Repository navigation
fwk: lotus: clamp typec_safety_level in update_safety_power_limit() (CPU stuck at ~600 MHz) - #95
Conversation
In LEVEL_TYPEC_1_5A the Type-C safety sub-level was incremented and decremented without bounds, while the ladder only stepped down when the counter was exactly TYPEC_SAFETY_LEVEL_0 (and only stepped up when it was exactly TYPEC_SAFETY_LEVEL_3). The hard throttle applied in LEVEL_PROCHOT cuts the battery discharge current, so the first tick after entering LEVEL_TYPEC_1_5A is usually a decrease tick: the counter goes 0 -> -1 -> -2 ... and never equals TYPEC_SAFETY_LEVEL_0 again. safety_level then never returns to LEVEL_PROCHOT, so throttle_ap(THROTTLE_OFF, THROTTLE_HARD, THROTTLE_SRC_BAT_DISCHG_CURRENT) is never called and the APU stays hard throttled (~600 MHz) until the EC resets, on AC as well as battery. Every tick, cypd_update_safety_table() also indexes the 4-entry safety_table[] with the out-of-range level and passes the result to cypd_select_pdo(); the PD controllers reject it and the EC logs "SET CCG_SELECT_REG failed" about once a second. Clamp the counter to [TYPEC_SAFETY_LEVEL_0, TYPEC_SAFETY_LEVEL_3]. Fixes: 9ff6a96 ("fwk: 16-inch: Reduce the Type-C current once the battery exceed discharge current limit") BRANCH=fwk-tulip-29169 BUG=FrameworkComputer/SoftwareFirmwareIssueTracker#243 TEST=Host simulation of the LEVEL_PROCHOT..LEVEL_COUNT cases. Without this change, PROCHOT followed by 20 decrease ticks leaves the ladder at LEVEL_TYPEC_1_5A with the counter at -20 and the throttle on; with it, the ladder returns to LEVEL_NORMAL and releases the throttle. 1,000,000 random ticks keep the counter within [0, 3]. Not yet built or run on hardware. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
I did use AI for this but it does solve THE CLAMP. It resolves https://community.frame.work/t/cpu-frequency-stuck-at-600-mhz/79713 |
|
Wait, holy crap, I experienced this on my FW16, you telling me it might not be hardware damage? I just requested a full replacement unit from them citing EC damage! I have the exact same report from my system every time I play a high octane game. They need to look at this. |
|
@erwynne if shutting down and unplugging the charger solves the clamp, the hardware fix isn't going to fix. I'd love if the Framework team could see this and fix it |
|
@mkornreich It solves it when I unplug and replug yes. It resets the EC. Their response to me when I gave them the logs was to tell me to use DDU, and me telling them that DDU wouldn't do anything because my PC was slow even in BIOS (and because their driver bundle currently includes a broken Nvidia Driver that will crash on lid sleep 50/50). I already requested a manager, so I'll send them here, maybe that can get this fixed. Here's my own error, which did lock it, just to back this up: Edit - I was doing some research on this and discovered in the process that the reason my framework tool never reported PROCHOT (as it didn't line up with everything whereas all other problems did) is the EC returns the hard-throttle source bitmask (throttle_get_state() in common/throttle_ap.c), but framework_tool compares it with an exact match Edit (five technically): If you're plugged in and "charging" (discharging) and there is a heavy load technically it should at least be able to charge and not have an issue. But because Smart Charging / battery sustaining currently has that issue, people who set their computer to 90% to maximize battery life will experience this, so: people using a charge limit to preserve their battery and gaming or compiling code while plugged in |
Problem
On the Laptop 16, heavy load that drains the battery can leave every CPU core hard-throttled at ~600 MHz until the EC loses power. Both boards are affected, since tulip and lotus both build
lotus/src/cpu_power.c.Unplugging or replugging the charger, OS reboots and power-profile changes don't clear it. While it's stuck, the EC console logs this for every PD port about once a second:
Reports of this:
Cause
In
update_safety_power_limit(),LEVEL_TYPEC_1_5Aincrements and decrementstypec_safety_levelwithout bounds, but only steps down when the counter equals exactlyTYPEC_SAFETY_LEVEL_0:LEVEL_PROCHOT. That assertsTHROTTLE_SRC_BAT_DISCHG_CURRENTand moves toLEVEL_TYPEC_1_5A, with the counter at 0.LEVEL_PROCHOT, soTHROTTLE_OFFfor that source is never sent.cypd_update_safety_table()indexes the 4-entrysafety_table[]with the negative value and passes the result tocypd_select_pdo(). The PD controllers reject it, which produces the console loop above.Where the code is:
It's unrelated to the PROCHOT pin fix in c6575ef.
Fix
Clamp
typec_safety_levelto[TYPEC_SAFETY_LEVEL_0, TYPEC_SAFETY_LEVEL_3]:LEVEL_PROCHOT, which releases the throttle on the next decrease.Testing
Host simulation of the
LEVEL_PROCHOT..LEVEL_COUNTcases, with the switch block copied verbatim:LEVEL_NORMAL, throttle releasedNot yet built or run on hardware. It should be reproducible on a unit with the existing console hooks:
Seen in the field on a Laptop 16 AI 300 (HX 370, BIOS 04.01): the CPU locked at 603–610 MHz after heavy CPU+GPU load on battery, with the console loop above. Only an EC power cycle cleared it.
🤖 Generated with Claude Code